/*
 * World.h
 *
 *  Created on: Jul 13, 2009
 *      Author: scott
 */

#ifndef WORLD_H_
#define WORLD_H_

#include <ode/ode.h>

#include "SceneGraphNode.h"

struct SAMPLE;

class World {
private:
	dWorldID world;
	dSpaceID space;
	dJointGroupID contactGroup;
	dBodyID body;
	SAMPLE * sample;
public:
	World(SceneGraphNode * root, SAMPLE * sample);

	virtual ~World();

	void update();

	// utitilities for converting between ode and opengl
	static float * ode2Opengl(float* M, const float* p, const float* R);
	static float * opengl2OdeR(float* R, const float* M);
	static float * opengl2OdeP(float * P, const float * M);

	// callbacks for collisions
	static void staticCollisionCallback(void * data, dGeomID o1, dGeomID o2);
	void collisionCallback(dGeomID o1, dGeomID o2);

    dJointGroupID getContactGroup() const
    {
        return contactGroup;
    }

    dSpaceID getSpace() const
    {
        return space;
    }

    dWorldID getWorld() const
    {
        return world;
    }

    void setContactGroup(dJointGroupID contactGroup)
    {
        this->contactGroup = contactGroup;
    }

    void setSpace(dSpaceID space)
    {
        this->space = space;
    }

    void setWorld(dWorldID world)
    {
        this->world = world;
    }

};

#endif /* WORLD_H_ */
